// Almost simple WYSIWYG Editor - text formatting and links  
tinyMCE.init({
	mode : "textareas",
	theme : "advanced",
	plugins : "inlinepopups",
	theme_advanced_buttons1 : "bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright, justifyfull,bullist,numlist,undo,redo,link,unlink",
	theme_advanced_buttons2 : "",
	theme_advanced_buttons3 : "",
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",
	extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
	editor_selector : "somewhatAdvanced",
	content_css : "http://www.nationaldb.org/css/stylesEditor.css"
	
});  
  
  // Advanced WYSIWYG Editor - all the bells and whistles
  /*
  tinyMCE.init({
  	mode : "textareas",
	theme : "advanced",
	editor_selector : "editorAdvanced",
    plugins : "inlinepopups,style,table,save,advhr,advimage,advlink,iespell,preview,zoom,media,searchreplace,print,contextmenu,paste,directionality,nonbreaking,xhtmlxtras",
	theme_advanced_buttons1 : "print,newdocument,undo,redo,|,bold,italic,underline,strikethrough,forecolor,backcolor,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,|,code",
	theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,|,link,unlink,anchor,image,|,preview",
	theme_advanced_buttons3 : "tablecontrols,|,sub,sup,|,iespell,ltr,rtl,|,styleprops,|,cite,abbr,acronym",
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",	
	extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
    file_browser_callback : 'myFileBrowser',
    onchange_callback : "",
    content_css : "http://www.nationaldb.org/css/stylesEditor.css"
  });
  
  // Very simple WYSIWYG Editor - text formatting only (B,I,U,etc.)
  tinyMCE.init({
	mode : "textareas",
	theme : "simple",
	editor_selector : "editorSimple",
	height:"100px",
	width:"300px",
	content_css : "http://www.nationaldb.org/css/stylesEditor.css"
  });
  */
  
	/*
	tinyMCE.init({
	mode : "textareas",
	theme : "simple",
	editor_selector : "mceSimple"
}); 
  */
  /*	
  function myFileBrowser (field_name, url, type, win) {
    var fileBrowserWindow = new Array();
    fileBrowserWindow['title'] = 'File Browser';
    fileBrowserWindow['file'] = "my_cms_script.php" + "?type=" + type;
    fileBrowserWindow['width'] = '420';
    fileBrowserWindow['height'] = '400';
    tinyMCE.openWindow(fileBrowserWindow, { window : win, resizable : 'yes', inline : 'yes' });
    return false;
  }
  */
function myFileBrowser (field_name, url, type, win) {
	//alert("Field_Name: " + field_name + "\nURL: " + url + "\nType: " + type + "\nWin: " + win); // debug/testing
	
	/* If you work with sessions in PHP and your client doesn't accept cookies you might need to carry
	   the session name and session ID in the request string (can look like this: "?PHPSESSID=88p0n70s9dsknra96qhuk6etm5").
	   These lines of code extract the necessary parameters and add them back to the filebrowser URL again. */
	
	//var cmsURL = window.location.pathname;      // script URL
	var callbackScript = '../../../../includes/fileBrowser.php';
	var searchString = window.location.search;  // possible parameters
	if (searchString.length < 1) {
	    // add "?" to the URL to include parameters (in other words: create a search string because there wasn't one before)
	    searchString = "?";
	}
	
	// newer writing style of the TinyMCE developers for tinyMCE.openWindow
	tinyMCE.openWindow({
		//file : cmsURL + searchString + "&type=" + type, // PHP session ID is now included if there is one at all
		file : callbackScript + searchString + 'type=' + type,
	    title : "File Browser",
	    width : 420,  // Your dimensions may differ - toy around with them!
	    height : 400,
	    close_previous : "no"
	}, {
	    window : win,
	    input : field_name,
	    resizable : "yes",
	    inline : "yes",  // This parameter only has an effect if you use the inlinepopups plugin!
	    editor_id : tinyMCE.getWindowArg("editor_id")
	});
	return false;
}	  
  